<template>
  <div>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in newsList" :key="item.id">
                <!-- 通过路由传递参数 -->
                <router-link :to="'/news/info/'+item.id">
                    <div>
                        <img class="mui-media-object mui-pull-left" :src="item.img_url">
                        <div class="test">
                            {{item.title | overF}}
                            <p>
                                <span>发表时间:{{item.add_item | timeFilter}}</span>
                                <span>点击次数:{{item.click}}</span>
                            </p>
                        </div>
                    </div>
                </router-link>
            </li>
        </ul>
  </div>
</template>
<script>
export default {
  data() {
    return {
      //   获取数据存储到数组里
      newsList: [],
      
    };
  },
  created() {
      this.getNewsList()
  },
  filters:{
      'overF':function(info){
          return info.substring(0,18)+'...';
      }
  },
  methods: {
    getNewsList() {
        this.$http.get('api/getnewslist').then((res)=>{
            // console.log(res.body)
            if(res.body.status ===0 ){
                this.newsList = res.body.message
            }
        })
    }
  }
};
</script>
<style lang="less" scoped>
.test{
    p{
        color: #26a;
        display: flex;
        justify-content: space-between;
    }
    
}
</style>